<?php
require(__DIR__ . '/environment.php');

if(APPLICATION_ENV === 'development') {
  (new \Phalcon\Debug())->listen(true, true);
}

$di = new \Phalcon\Di\FactoryDefault();

$di -> setShared('router', function () {
  $router = new \Phalcon\Mvc\Router(false);
  //$router -> removeExtraSlashes(true);

  $router -> setDefaultModule('frontend');
  $router -> setDefaultController('Index');
  $router -> setDefaultAction('index');

  $router -> mount(include __DIR__ . '/modules/backend/router.php');
  $router -> mount(include __DIR__ . '/modules/captcha/router.php');
  $router -> mount(include __DIR__ . '/modules/frontend/router.php');

	$router -> mount(include __DIR__ . '/modules/skinov/router.php');
  return $router;
});

$application = new Phalcon\Mvc\Application($di);

$application -> registerModules([
  'backend' => [
    'className' => 'Modules\\Backend\\Module',
    'path' => __DIR__ . '/modules/backend/Module.php'
  ],
  'captcha' => [
    'className' => 'Modules\\Captcha\\Module',
    'path' => __DIR__ . '/modules/captcha/Module.php'
  ],
  'frontend' => [
    'className' => 'Modules\\Frontend\\Module',
    'path' => __DIR__ . '/modules/frontend/Module.php'
  ],
  'skinov' => [
    'className' => 'Modules\\Skinov\\Module',
    'path' => __DIR__ . '/modules/skinov/Module.php'
  ]
]);

$application -> handle() -> send();